package cn.agiledata.security.db.dao;

import java.util.HashMap;
import java.util.Map;

import org.hibernate.SessionFactory;

import cn.agiledata.security.db.form.EnctSelectForm;
import cn.agiledata.security.db.service.IAvoidJuggleService;

import cn.agiledata.bank.common.dao.HqlPageListTemplate;
import cn.agiledata.bank.common.util.Constant;
import com.vnv.infrastructure.logic.IPBAppFactory;

public class EnctListPage extends HqlPageListTemplate implements Constant {
	private EnctSelectForm form;
	
	
	public EnctListPage(EnctSelectForm form) {

		this.setSessionFactory((SessionFactory) IPBAppFactory.getObj("sessionFactory"));
	
		this.form = form;
	}

	public String getHql() {
		StringBuffer sb = new StringBuffer();
		if(ACCOUNT_DB.equals(form.getDbName())) {
			sb.append(" select new cn.agiledata.security.db.bean.EnctListBean(obj) from Account obj ");
		}
		if(ACCOUNT_BALANCE_DB.equals(form.getDbName())) {
			sb.append(" select new cn.agiledata.security.db.bean.EnctListBean(obj) from AccountBalance obj ");
		}
		if(TRANSACTION_DB.equals(form.getDbName())) {
			sb.append(" select new cn.agiledata.security.db.bean.EnctListBean(obj) from Transaction obj ");
		}
		
		//检验码为空
		if(ENCRCODEEMPTY_ERROR_CODE.equals(form.getResultType())) {
			sb.append(" where obj.encryptCode is null ");
		}
		
		sb.append(" order by obj.id desc ");
		return sb.toString();
	}

	public Map getParams() {
		Map map = new HashMap();
		
		return map;
	}

	public String getStartPage() {
		// TODO 自动生成方法存根
		return form.getStartPage();
	}

	public String getPageRecord() {
		// TODO 自动生成方法存根
		return form.getPageSize();
	}
	
	//是否需要取total
	public boolean isNeedTotal() {
		return form.isNeedTotal();
	}
	//是否需要取list
	public boolean isNeedList() {
		return form.isNeedList();
	}
	//如果需要total,则count为传递进来的值
	public int needTotalCount() {
		return form.getNeedTotalCount();
	}

}
